import random


class TestGenerator:
    @staticmethod
    def generate_test_cases(count=5):
        """
        生成随机测试用例
        :param count: 生成的测试用例数量
        :return: List[Tuple[List[int], int]]，包含(nums, expected)的列表
        """
        test_cases = []
        for _ in range(count):
            # 随机生成数组长度和多数元素
            n = random.randint(1, 20)
            majority = random.randint(-10 ** 9, 10 ** 9)
            # 确保多数元素出现次数 > n//2
            majority_count = random.randint(n // 2 + 1, n)
            # 生成数组：多数元素 + 其他随机元素
            nums = [majority] * majority_count
            other_elements = [random.randint(-10 ** 9, 10 ** 9) for _ in range(n - majority_count)]
            nums.extend(other_elements)
            random.shuffle(nums)  # 打乱顺序
            test_cases.append((nums, majority))

        # 添加手动测试用例
        manual_cases = [
            ([3, 2, 3], 3),
            ([2, 2, 1, 1, 1, 2, 2], 2),
            ([1], 1),
            ([1, 1, 2], 1),
            ([-1, -1, -1, 0, 0, 1, -1], -1)
        ]

        return manual_cases + test_cases